$(()=>{
    $.get('http://localhost:5600/category',(data)=>{
        let url=location.search;
        let id=url.split('=')[1];

        data.data.forEach(item => {
            let html=`
                <option value="${item.id}">${item.cate_name}</option>
            `
            $('#category').append(html);
        });

        if (id) {
            $.get(`http://localhost:5600/blog/${id}`,(res)=>{
                let tmp=res.data
                console.log(tmp);
                $('#trId').show()
                $('#id').val(tmp.id)
                $('#title').val(tmp.title)
                $('#abstract').val(tmp.abstract)
                $('#body').val(tmp.body)
                $('#author').val(tmp.author)
                $('#category').val(tmp.cateId)
            })

        }
        
        
    })
})

function btnCancel() {
    window.location.href = './index.html'
}